<?php


class Blackbird_Form_Users_ChangeProfile extends Zend_Form
{
	function __construct($options = null)
	{
		parent::__construct($options);

		$translateValidators = new Zend_Config(require LIBRARY_PATH . '/Blackbird/language/es/validators.php');
		Zend_Validate_Abstract::setDefaultTranslator(new Zend_Translate('array', $translateValidators->toArray()));

		$translateCountries = new Zend_Config(require LIBRARY_PATH . '/Blackbird/language/es/countries.php');
		$countryOptions = $translateCountries->toArray();

		$genderOptions = array(
			'F' => ' Femenino',
			'M' => ' Masculino',
		);

		$this
			->addElement('hash', 'csrf')

			->addElement('text', 'firstname', array(
				'filters' => array('StripTags', 'StringTrim'),
				'label' => 'Nombres:',
				'maxlength' => 100,
				'required' => true,
				'style' => 'width:350px',
				'validators' => array(array('StringLength', true, array('min' => 2, 'max' => 100))),
			))

			->addElement('text', 'lastname', array(
				'filters' => array('StripTags', 'StringTrim'),
				'label' => 'Apellidos:',
				'maxlength' => 100,
				'required' => true,
				'style' => 'width:350px',
				'validators' => array(array('StringLength', true, array('min' => 2, 'max' => 100))),
			))

			->addElement('select', 'country', array(
				'label' => 'País:',
				'multiOptions' => $countryOptions,
				'style' => 'width:350px',
			))

			->addElement('text', 'state', array(
				'filters' => array('StripTags', 'StringTrim'),
				'label' => 'Departamento o estado:',
				'maxlength' => 100,
				'style' => 'width:350px',
				'validators' => array(array('StringLength', true, array('min' => 0, 'max' => 100))),
			))

			->addElement('text', 'city', array(
				'filters' => array('StripTags', 'StringTrim'),
				'label' => 'Ciudad:',
				'maxlength' => 100,
				'style' => 'width:350px',
				'validators' => array(array('StringLength', true, array('min' => 0, 'max' => 100))),
			))

			->addElement('radio', 'gender', array(
				'label' => 'Género:',
				'maxlength' => 100,
				'multiOptions' => $genderOptions,
			))

			->addElement('text', 'birthDate', array(
				'class' => 'date',
				'label' => 'Fecha: de nacimiento',
				'maxlength' => 10,
				'validators' => array('Date'),
				'style' => 'width:7em',
			))

			->addElement('button', 'submit', array(
				'label' => 'Cambiar Perfil',
				'ignore' => true,
				'type' => 'submit',
			))

			->addElement('button', 'cancel', array(
				'label' => 'Cancelar',
				'ignore' => true,
				'type' => 'button',
				'onclick' => 'history.go(-1)',
			))
			;

		$this->csrf
			->removeDecorator('DtDdWrapper')
			->removeDecorator('Label');

		$this->submit
			->removeDecorator('DtDdWrapper')
			->addDecorator('HtmlTag', array(
				'class' => 'buttons',
				'openOnly' => true,
				'placement' => Zend_Form_Decorator_Abstract::PREPEND,
				'tag' => 'dd',
			));

		$this->cancel
			->removeDecorator('DtDdWrapper')
			->addDecorator('HtmlTag', array(
				'closeOnly' => true,
				'placement' => Zend_Form_Decorator_Abstract::APPEND,
				'tag' => 'dd',
			));
	}
}

